#pragma region Description
/*
     Copyright © 2011 Jesse 'LorgonJortle' Wilkerson
     See licensing in source (.cpp) file, or at:
     <http://www.gnu.org/licenses/> (GPL)

     File: Mouse.h
     Author: Jesse 'LorgonJortle' Wilkerson
     Description:
          The static Mouse class keeps track of the
          current mouse state. It says where the mouse
          is, whether or not it's in the game window, and
          if any of the buttons are pressed. Functions can
          be specified for callback when a certain event
          happens (such as a mouse button pressed), too.
*/
#pragma endregion

#ifndef MOUSE_H
#define MOUSE_H

/*****************************************
                              OpenGL
*****************************************/
     #ifdef __APPLE__
         #include <SDL/SDL.h>
         #include <glew.h>
     #else
         #include <GL/glew.h>
         #include <SDL.h>
     #endif
/****************************************/

/*****************************************
                         Standard C++
*****************************************/
     #include <iostream>
/****************************************/

/*****************************************
                         LOGL::GLib
*****************************************/
     /*****************************************
                                   Common
     *****************************************/
          #include "Vector2.h"
/****************************************/

using namespace LOGL_GLib::Common;

namespace LOGL_GLib
{
    namespace Input
    {
          /* The buttons that can be pressed on a mouse. */
          enum MouseButton
          {
               Mouse_Left = 1,
               Mouse_Middle,
               Mouse_Right,
               Mouse_Scroll_Up,
               Mouse_Scroll_Down
          }; /* Enum MouseButton. */

          /* The two states a mouse button can be. */
          enum MouseButtonState
          {
               Mouse_Pressed,
               Mouse_Released
          }; /* Enum MouseButtonState. */

          /* Static Mouse class that maintains the current mouse state. */
          class Mouse
          {
          public:
               /* Gets the current mouse position. */
               static Vector2 Position();
               /* Gets the current mouse X position. */
               static GLuint X();
               /* Gets the current mouse Y position. */
               static GLuint Y();
               /* Gets the scroll value for the mouse. */
               static GLint Scroll();
               /* Gets whether or not the specified mouse button is down. */
               static GLboolean IsButtonDown(MouseButton _Button);
               /* Gets whether or not the specified button is pressed, but was not pressed last update. */
               static GLboolean IsNewButtonDown(MouseButton _Button);
               /* Swaps the current and previous button state buffers. */
               static GLvoid SwapBuffers();
               /* Sets the mouse click callback. */
               static GLvoid ClickFunc(GLvoid (*_mouseFunc)(MouseButton _Button, MouseButtonState _State));
               /* Sets the mouse motion callback. */
               static GLvoid MotionFunc(GLvoid (*_motionFunc)(GLint _X, GLint _Y, GLint _DeltaX, GLint _DeltaY));
               /* Changes mouse state to represent the button action. */
               static GLvoid Click(GLint _Button, GLint _State);
               /* Updates the mouse's position state. */
               static GLvoid Motion(GLint _X, GLint _Y, GLint _DeltaX, GLint _DeltaY);
               /* Toggles the visibility of the cursor. */
               static GLvoid ToggleCursor();

          private:
               /* The X position of the mouse (relative to the window). */
               static GLuint x;
               /* The Y position of the mouse (relative to the window). */
               static GLuint y;
               /* The scroll value of the mouse. */
               static GLint scroll;
               /* The three mouse button states. */
               static GLboolean buttons[3];
               /* The previous cycle's button states. */
               static GLboolean previousButtons[3];
               /* Function pointer to mouse click callback. */
               static GLvoid (*clickFunc)(MouseButton _Button, MouseButtonState _State);
               /* Function pointer to mouse motion callback. */
               static GLvoid (*motionFunc)(GLint _X, GLint _Y, GLint _DeltaX, GLint _DeltaY);
        }; /* Class Mouse. */

    } /* Namespace Input. */
} /* Namespace LOGL_GLib. */

#endif
